package com.itheima.day09.Zuoye;

import java.time.LocalTime;
import java.util.*;

public class ZuoYe1 {
    public static void main(String[] args) {
        Map<Integer, String> map = new TreeMap<>();
        String[] stationNames = {"中心广场", "人民公园", "火车站",
                "机场", "大学城", "科技园", "体育中心", "医院",
                "博物馆", "图书馆", "动物园", "植物园", "海洋公园",
                "高铁站", "汽车站", "码头", "工业区", "商业中心",
                "住宅区", "政府大楼"};
        for (int i = 0; i < stationNames.length; i++) {
            map.put(i+1, stationNames[i]);
        }
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入上车站：");
        String start = sc.next();
        while (!map.containsValue(start)){
            System.out.println("站点不存在，请重新输入！");
            start = sc.next();
        }
        System.out.println("请输入下车站：");
        String end = sc.next();
        while (!map.containsValue(end)){
            System.out.println("站点不存在，请重新输入！");
            end = sc.next();
        }
        int s = 0;
        int e = 0;
        int price = 0;
        LocalTime time = LocalTime.now();
        System.out.println(time.getMinute());
        Set<Map.Entry<Integer, String>> entries = map.entrySet();
        for (Map.Entry<Integer, String> entry : entries) {
            if(Objects.equals(start, entry.getValue())) {
            s = entry.getKey();
            }
            if(Objects.equals(end, entry.getValue())){
                e = entry.getKey();
            }
        }
        if(Math.abs(s-e)<=3){
            price = 3;
            LocalTime T1 = time.plusMinutes(Math.abs(s-e)*3);
            System.out.println("从"+start+"，到"+end+"，票价为："+price+"，所需时间为："+T1+"共计："+Math.abs(s-e)*3+"分钟");
        }else if (Math.abs(s-e)>3 && Math.abs(s-e)<=5){
            price = 4;
            LocalTime T1 = time.plusMinutes(Math.abs(s-e)*3);
            System.out.println("从"+start+"，到"+end+"，票价为："+price+"，所需时间为："+T1+"共计："+Math.abs(s-e)*3+"分钟");

        }else if (Math.abs(s-e)>5&&(Math.abs(s-e)-5)*2+4<10){
            price = (Math.abs(s-e)-5)*2+4;
            LocalTime T1 = time.plusMinutes(Math.abs(s-e)*3);
            System.out.println("从"+start+"，到"+end+"，票价为："+price+"，所需时间为："+T1+"共计："+Math.abs(s-e)*3+"分钟");
            }else{
                price = 10;
                LocalTime T2 = time.plusMinutes(Math.abs(s-e)*3);
                System.out.println("从"+start+"，到"+end+"，票价为："+price+"，所需时间为："+T2+"，共计："+Math.abs(s-e)*3+"分钟");
            }
        }
}

